#include<stdio.h>
#include<string.h>
#define N 1000

void count (char s[N])
{
	int i;
	int sum=0;
	for(i=0;s[i]!=0;i++)
	{
		if(s[i]=='2')
		{
			sum++;
		}
	}
	printf("%d\n",sum);
	
}
int main ()
{
	char s[N];
	while(gets(s)!=NULL)
	{
		count(s);
	}
	return 0;
}
